package com.mingle.iwalk;

import android.database.Cursor;

public abstract class TravelerInfo
{
	public static	int 	INFO_INVALID_ID 		= -1;
	
	public static 	int 	INFO_TYPE_UNKNOWN		= 0;
	public static 	int 	INFO_TYPE_POI			= 1;
	public static 	int 	INFO_TYPE_TRACK			= 2;

	public static 	int 	TAG_TYPE_NONE			= 0;
	public static 	int 	TAG_TYPE_FOOD			= 1;
	public static 	int 	TAG_TYPE_INTERESTING 	= 2;
	
	public			int 	id 						= INFO_INVALID_ID;
	public			int 	uuid 					= INFO_INVALID_ID;
	public 			int 	type 					= INFO_TYPE_UNKNOWN;
	public 			String 	title			 		= "";
	public 			String 	description 			= "";
	public 			long  	createTime 				= 0;
	public 			boolean uploadFlag 				= false;
	public 			long  uploadTime 				= 0;
	public 			int		tagType 				= TAG_TYPE_NONE;
	public			String 	workingFolderPath 		= "";
	
	public abstract TravelerInfo convert2TravelerInfo(Cursor cursor);
	
	public TravelerInfo convert2TravelerInfoBase(Cursor cursor)
	{
		this.id			= cursor.getInt(cursor.getColumnIndex(TravelerDB._ID));
		try
		{
			this.uuid 		= cursor.getInt(cursor.getColumnIndex(TravelerDB.UUID));
		}
		catch (Exception e)
		{
			this.uuid = INFO_INVALID_ID;
		}
		
		this.type 		= cursor.getInt(cursor.getColumnIndex(TravelerDB.TYPE));
		this.title 		= cursor.getString(cursor.getColumnIndex(TravelerDB.TITLE));
		this.description= cursor.getString(cursor.getColumnIndex(TravelerDB.DESCRIPTION));
		this.createTime = cursor.getLong(cursor.getColumnIndex(TravelerDB.CREATED_TIME));
		this.uploadFlag = cursor.getInt(cursor.getColumnIndex(TravelerDB.UPLOAD_FLAG))==0?false:true;
		this.uploadTime = cursor.getLong(cursor.getColumnIndex(TravelerDB.UPLOAD_TIME));
		this.tagType 	= cursor.getInt(cursor.getColumnIndex(TravelerDB.TAG));
		this.workingFolderPath = cursor.getString(cursor.getColumnIndex(TravelerDB.WORKING_FOLDER_PATH));
    	
		return this;
	}
}
